<?php
$this->breadcrumbs = array(
    UserModule::t("Users"),
);
?>

<h1><?php echo UserModule::t("List User"); ?></h1>

<?php
if (UserModule::isAdmin()) {
    $this->menu = array(
        array('label' => UserModule::t('Manage User'), 'url' => array('/user/admin')),
        array('label' => UserModule::t('Manage Profile Field'), 'url' => array('profileField/admin')),
    );
    ?><?php } ?>
<?php
$pageSize = Yii::app()->user->getState('pageSize');
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'user-grid',
    'dataProvider' => $dataProvider,
    //'selectionChanged' => 'function(id){document.location.href="' . $this->createUrl('/user/admin/view/id/') . '/"+$.fn.yiiGridView.getSelection(id)}',
    'columns' => array(
        array(
            'name' => 'username',
            'type' => 'raw',
            'value' => 'CHtml::link(CHtml::encode($data->username),array("user/view","id"=>$data->id))',
        ),
        array(
            'name' => 'createtime',
            'value' => 'date("d.m.Y H:i:s",$data->createtime)',
        ),
        array(
            'name' => 'lastvisit',
            'value' => '(($data->lastvisit)?date("d.m.Y H:i:s",$data->lastvisit):UserModule::t("Not visited"))',
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '',
            'footer' => 'Items: ' . CHtml::dropDownList('pageSize', $pageSize, array(
                $pageSize => $pageSize,
                20 => 20,
                50 => 50,
                100 => 100), array(
                // change 'user-grid' to the actual id of your grid!!
                'onchange' => "$.fn.yiiGridView.update('user-grid',{ data:{pageSize: $(this).val() }})",
            )),
        ),
    ),
));
?>
